#!/usr/bin/env python
# -*- coding: UTF-8 -*-
# @Project : chat_model 
# @File    : schema.py
# @IDE     : PyCharm 
# @Author  :ZH
# @Time    : 2025/1/10 14:59
from datetime import datetime

from pydantic import BaseModel
from typing import Optional, List

from apps.utils.enumerate import KnowledgeFileStateEnum


class KnowledgeListRequests(BaseModel):
    page: int = 1
    limit: int = 10
    name: str = None


class KnowledgeListResponseBase(BaseModel):
    id: Optional[int] = None
    update_date: Optional[datetime] = None
    knowledge_name: Optional[str] = None
    description: Optional[str] = None
    embedding_server_id: Optional[int] = None


class KnowledgeListResponse(BaseModel):
    code: int
    message: str
    count: Optional[int] = None
    data: Optional[List[KnowledgeListResponseBase]] = None


class KnowledgeCreateRequests(BaseModel):
    knowledge_name: str
    description: Optional[str] = None
    embedding_server_id: int


class DefaultKnowledgeResponse(BaseModel):
    code: int
    message: str


class CreateKnowledgeResponse(DefaultKnowledgeResponse):
    data: Optional[int] = None


class KnowledgeFileListRequests(BaseModel):
    knowledge_id: int
    page: int = 1
    limit: int = 10
    name: str = None


class KnowledgeFileListResponseBase(BaseModel):
    id: Optional[int] = None
    update_date: Optional[datetime] = None
    file_name: Optional[str] = None
    file_size: Optional[int] = None
    state: Optional[KnowledgeFileStateEnum] = None


class KnowledgeFileListResponse(BaseModel):
    code: int
    message: str
    count: Optional[int] = None
    data: Optional[List[KnowledgeFileListResponseBase]] = None


class KnowledgeFileHandle(BaseModel):
    knowledge_id: int
    file_id: int
    # 设置大小不能超过4096
    split_size: Optional[int] = 1024
    # 分词方式
    split_str: Optional[str] = '\n'
    # 文本提取方法
    file_extract_id: Optional[int] = None


class KnowledgeInfoResponseBase(BaseModel):
    id: Optional[int] = None
    update_date: Optional[datetime] = None
    knowledge_name: str
    description: Optional[str] = None


class KnowledgeInfoResponse(BaseModel):
    code: int
    message: str
    data: KnowledgeInfoResponseBase
